<%--
  Created by IntelliJ IDEA.
  User: sicilin
  Date: 2017/7/31
  Time: 10:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../commons-easyui.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>共享对象页面</title>
    <!-- 定制化的js -->
    <script type="text/javascript" src="<%=basePath%>common/script/customize/customize-old.js"></script>
    <script type="text/javascript" src="<%=basePath%>common/script/customize/object/object.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/object/object.js"></script>
    <script type="text/javascript" src="<%=basePath%>js/object/objectType.js"></script>
    <script type="text/javascript">
        /*----------  自定义全局变量部分  ----------*/
        var editIndex = -1; //编辑行号
        var selectTreeObject = {};
        var objectSubmitMode = '';


        /*----------  页面加载部分  ----------*/
        $(document).ready(function () {
            initCombo();
        });

        /*---------- 自定义js方法部分 ----------*/
        function initTree(rootId){
            $('#objectTree').tree({
                url:basePath+'objectAction/findByTree.json'
                ,queryParams:{'parentId':rootId}
                ,method:"post"
                ,onClick:function(node){
                    //调用ifarme子窗口linkFunction方法
                    var linkFn =$(window.parent.document).contents().find("#objectFrame")[0].contentWindow.linkFunction;
                    if(typeof linkFn == 'function'){
                        linkFn(node);
                    }
                }

            });
        }

        function initTree2(objectCodes){
            tmsObject.tree($('#objectTree'),objectCodes,function(node){
                var linkFn =$("#objectFrame")[0].contentWindow.linkFunction;
                if(typeof linkFn == 'function'){
                    linkFn(node);
                }
            });
        }

        function initCombo(){
            $('#objectTypeCombo').combo({
                required:true
                ,editable:false
                ,missingMessage:'请选择类别'
                ,onShowPanel:function(){
                }
            });
            initComboPanel($('#objectTypeCombo').combo('panel'));
        }

        //在面板中初始化下拉项
        function initComboPanel(panel){
            var textBox = $('<input id ="searchBox" />');
            var ul = $('<ul id = "comboList"></ul>');
            panel.append(textBox);
            panel.append(ul);
            textBox.textbox({
                buttonIcon:'icon-search'
                ,width:panel.css('width')-20
                ,onClickButton:function(){
                    var text = textBox.textbox('getText');
                    ul.datalist('load',{'text':text});
                }
            });
            ul.datalist({
                url:basePath+'objectAction/searchObjectType.json'
                ,method:'post'
                ,height:170
                ,queryParams:{'text':''}
                ,valueField:'id'
                ,textFormatter:function (value,row,index) {
                    return row.objectName+'('+row.objectCode+')';
                }
                ,border:false
                ,onSelect:function(index,row){
                    ul.datalist('unselectRow',index);
                }
                ,onClickRow:function(index, row){
                    $('#objectTypeCombo').combo('setText',row.objectName+'('+row.objectCode+')');
                    $('#objectTypeCombo').combo('setValue',row.objectId);
                    $('#objectTypeCombo').combo('hidePanel');
//                    initTree(row.objectId);
                    initTree2([row.objectCode]);
                    showPage(row.objectCode);
                }
            });
        }

    </script>
</head>
<body>
    <!-- 面板区域 -->
    <div id = "objectLayout" class="easyui-layout" data-options="fit:true">
        <div data-options="region:'west',title:'树形对象'" style="width:300px;">
            <div class="easyui-panel" data-options="noheader:true,border:false" style="height:50px;padding:10px;">
                <input id = "objectTypeCombo" style="width:170px;"/>
                <a id = "openTypeBtn" class="easyui-linkbutton" onclick="openOrInitDialog('objectTypeDialog','类别管理',initTypeDatagrid)" data-options="iconCls:'icon-man'" style="">类别管理</a>
            </div>
            <hr width="90%" style=" height:2px;border:none;border-top:2px solid  #99ccff;" />
            <div class = "easyui-panel" data-options="border:false,fit:true" style="padding: 10px;">
                <a id = "openAddObjectBtn" class="easyui-linkbutton" onclick="openOrInitDialog('objectDialog','对象管理',null,null,initObjectDialog,'add')" data-options="iconCls:'icon-add'" style="margin:0px 2px;">添加</a>
                <a id = "openUpdObjectBtn" class="easyui-linkbutton" onclick="openOrInitDialog('objectDialog','对象管理',null,null,initObjectDialog,'edit')" data-options="iconCls:'icon-edit'" style="margin:0px 2px;">修改</a>
                <div id = "objectTree" style="margin-top:10px;"></div>
            </div>
        </div>
        <div id="objectInfoPanel" data-options="region:'center',title:'对象的关联信息'">
            <iframe id="objectFrame"  frameborder="0" style="width:100%;height:100%"></iframe>
        </div>
    </div>
    <!---------------- 华丽丽的分割线 ---------------->
    <!-- dialog区域 -->
    <div id = 'objectTypeDialog'style="display: none;width:500px;height:400px;">
        <table id = "typeDatagrid" init-flag = "false"></table>
        <div id = 'typeDatagridToolbar'></div>
    </div>
    <div id = 'objectDialog' style="display:none;width:250px;padding:0px 20px 0px 20px;">
        <div id = "addFormDiv" style="padding: 10px 20px 0px 20px;">
            <div style="margin: 0px 0px;height: 25px;line-height:25px;">
                <a title="选择的对象" class="easyui-tooltip" data-options="position:'top'"><span id="selectObjectTip" style="font-size:14px;font-weight: bolder;color:#b52b27"></span></a>
            </div>
            <div style="margin: 10px 0px;height: 25px;">
                <select id="addMode" name="addMode" class="easyui-combobox" data-options="fit:true" >
                    <option value="1" selected >添加子项</option>
                    <option value="0">添加同辈</option>
                </select>
            </div>
            <hr/>
        </div>
        <form id = "objectForm" method="post" >
            <div style="margin:10px 0px;height: 25px;">
                <label style="width: 30%">对象编号</label>
                <input id="objectCode" name="objectCode" class="easyui-validatebox textbox" style="width: 60%;height: 100%" />
            </div>
            <div style="margin: 10px 0px;height: 25px;">
                <label style="width: 30%">对象名称</label>
                <input id="objectName" name="objectName" class="easyui-validatebox textbox" style="width: 60%;height: 100%" />
            </div >
            <div style="margin: 10px 0px;height: 25px;" id = "folderDiv">
                <label style="width: 30%">是否为文件夹</label>
                <input type="radio" name="folder" value="true"> 是
                <input type="radio" checked name="folder" value="false"> 否
            </div>
            <div style="width: 100%;height:30px;position:relative;margin-top:10px;">
                <a class="easyui-linkbutton" data-options="fit:true" onclick="submitObjectForm()" >提交</a>
            </div>
        </form>
    </div>
</body>
</html>
